#ifndef DRIVEDATABASE_H
#define DRIVEDATABASE_H
#include <string>
#include "database.h"
#include <map>
#include <set>
#include <iostream>
#include <iterator>
#include <map>
#include <fstream>
#include "sys/types.h"
#include "sys/param.h"
#include "sys/stat.h"
#include "dirent.h"
#include <vector>
#include <sstream>


using namespace std;

class drivedatabase : public database_interface {


	public:
		drivedatabase();
		~drivedatabase();
	
		bool create_newsgroup(string group);

		/* Creates a news entry.*/
		pair<bool, unsigned int> put(const unsigned int group, const string title, const string author, const string text);

		/* Retrieves a news entry.*/
		pair<int, map<string, string> > get(const unsigned int group_id, const unsigned int article_id);
	
		vector<pair<unsigned int, string> > get_newsgroups();

		bool remove_newsgroup(const unsigned int group_id);

		vector<pair<unsigned int, string> > get_news_entries(unsigned int group);

		/* Removes a news entry.*/
		int remove(const unsigned int group_id, const unsigned int article_id);
		int get_id(string filepath);
		vector<string> list(string path, int type = 0);
	private :
		string root;

		bool ng_exist(int ng_id);
		string get_ng_name(int ng_id);
		string get_path(int ng_id, string file = "");
		int increment_id(string filepath);
		int file_status(string str);


};

#endif
